<?php
require_once("funcionesBase.php");
$tabla = $_GET['tabla'];



echo '				<div class="modal fade" id="modeloMensaje" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
						<div class="modal-dialog moMensaje">
							<div class="modal-content moMensaje" id="cuerpoMensaje">
								
							</div>
						</div>
					</div>';


echo '				<div class="modal fade" id="modeloNuevaTabla" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
						<div class="modal-dialog moNuevaTabla">
							<div class="modal-content moNuevaTabla" id="cuerpoNuevaTabla">
								
							</div>
						</div>
					</div>';

?>


<div class="panel panel-primary">					
	
	<div class="panel-heading">
		<div class="row">
			<div class="col-md-5">
				<span class="glyphicon glyphicon-list-alt"></span>
				<?php
                	echo $tabla; 	
				?>
			</div>
			<div class="col-md-15 tdDerecha">
				<button id="btnNuevaTabla" type="button" class="btn btn-success tdDerecha btn-sm" data-toggle="modal" data-target="#modeloNuevaTabla" >
					<span class="glyphicon glyphicon-plus-sign"></span>
					Nueva tupla
				</button>
			</div>
		</div>
	</div>
 
<table class="table table-striped table-hover table-bordered table-condensed">
                       
	<tr>
    <?php
    	$columnas= getColumnas( $tabla );
		while($unaColumna = mysql_fetch_array($columnas))
		{
			echo '<th>'.$unaColumna['Field'].'</th>';
		}
		
	?>
    	<th>Acciones</th>
    <tr>
    
    <?php
		$tuplas= getTuplas( $tabla );
		$contE=0;
    	while($unaTupla = mysql_fetch_array( $tuplas ))
		{
			echo '<tr>';
			$columnas= getColumnas( $tabla );
			
			while($unaColumna = mysql_fetch_array($columnas))
			{
				echo '
					<td>'.$unaTupla[ $unaColumna['Field'] ].'</td>
				';
			}

/*
					<button type="button" class="btn btn-primary btn-sm" '.
					'id="modificarTupla'.$unaTupla[ $unaColumna['Field'] ].
					'" data-toggle="modal" data-target="#modeloNuevaTabla">
					
						<span class="glyphicon glyphicon-edit"></span>
							Modificar					
					</button>
				*/
			echo '
				<td>';
			echo '	
								<div class="btn-group">
									<button type="button" class="btn btn-danger btn-sm" '.
									'id="Eli'.$contE.'" data-toggle="modal" data-target="#modeloMensaje">
										<span class="glyphicon glyphicon-trash"></span>
										Eliminar
									</button>
								</div>

				</td>
				';

			echo '</tr>';
			
			
			echo '
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>		
	$( "#Eli'.$contE.'" ).mouseup(function() {
		$( "#cuerpoMensaje" ).load("elTupla.php?tabla='.$tabla.'&idEliminar='.$contE.'");
		
	});

</script>
';
		$contE++;
			
		}
	?>

</table>
</div>    

